import { Object3D, Texture, TextureLoader, Vector2 } from "three";
import Config from "../../../application/constants/Config";
import { WaterUtil } from "./WaterUtil";
import Helper from "../../../utils/Helper";

export default class WaterUtilty {
    public static setWater(obj: Object3D, options: {
        color: string,
        scale: number,
        reflectivity: number,
        flowX: number,
        flowY: number
    }){
        //把options中没有的属性，从Config.WaterConfig中写入到options中
        let param:any = { ...Config.WaterConfig, ...options };

        const textureLoader = new TextureLoader();
        param.normalMap0 = textureLoader.load(param.normalMap0);
        param.normalMap1 = textureLoader.load(param.normalMap1);

        param.flowDirection = new Vector2(param.flowX, param.flowY);

        if(param.refractMap){
            param.refractMap = textureLoader.load(param.refractMap);
        }

        let waterMaterialUtil = new WaterUtil();
        waterMaterialUtil.setWaterForObj3D(obj, param);

    }
}